#ifndef __BLACKBOX_BOXES_DC1394_CDC1394CAMERA_H__
#define __BLACKBOX_BOXES_DC1394_CDC1394CAMERA_H__

#include <blackbox/blackbox.h>
#include <dc1394/control.h>

namespace buola { namespace blackbox {

class CDC1394;
    
class CDC1394Camera : public UUncopiable
{
private:
    CDC1394Camera(CDC1394 *pDC,dc1394camera_t *pCam);
    
public:
    ~CDC1394Camera();

    void Initialize(bool pCleanupChannels);
    void Start();
    void Stop();

    void SetROI();
    void SetFrameRate(dc1394framerate_t pRate);
    void SetISOSpeed(dc1394speed_t pSpeed);
    void SetMode(dc1394video_mode_t pMode);

    void SetBayerFilter(dc1394color_filter_t pBayerFilter);

    void SetWhiteBalance(int p1,int p2);
    void SetImageSize(const CSize_i &pSize,dc1394video_mode_t pMode);
    void SetImagePos(const CPoint_i &pPos,dc1394video_mode_t pMode);

    void SetFeature(int pFeature,unsigned int pValue);
    void SetFeatureAbs(int pFeature,double pValue);
    void SetFeature(int pFeature,unsigned int p1,unsigned int p2);
    void SetFeature(int pFeature,unsigned int p1,unsigned int p2,unsigned int p3);
    void SetFeatureMode(int pFeature,int pMode);

    uint32_t GetControlRegister(off_t pOffset);
    void SetControlRegister(off_t pOffset,uint32_t pValue);

    void DequeueFrame(dc1394video_frame_t **pFrame);
    void EnqueueFrame(dc1394video_frame_t *pFrame);

    void PrintInfo(io::CTextWriter &pStream);

    uint64_t GetUUID()  {   return mCam->guid;  }
    
    dc1394camera_t *GetDC1394Camera()   {   return mCam;    }

private:
    CDC1394 *mDC;
    dc1394camera_t *mCam;
    bool mIsInit;
    bool mIsStarted;

    dc1394featureset_t mFeatureSet;
    dc1394speed_t mISOSpeed;
    dc1394video_modes_t mModes;
    dc1394video_mode_t mMode;
    dc1394framerate_t mFrameRate;
    dc1394color_filter_t mBayerFilter;
    
    friend class CDC1394;
};

/*namespace blackbox*/ } /*namespace buola*/ }

#endif